<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateTableStudy extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('student', function (Blueprint $table) {

            $table->bigIncrements('id');
            $table->char('stu_num',12)->comment('学号，学生唯一标识，用于登录')->nullable();
            $table->addColumn('string','nick_name',['length'=>32])->comment('用户自定义的名称');
            $table->addColumn('string', 'class',['length' => 32])->comment('班级')->nullable();
            $table->string('grade',16)->comment('年级')->nullable(false);
            $table->string('password', 255)->comment('密码')->nullable(false);
            $table->string('sale', 16)->comment('密码盐')->nullable(false);
            $table->string('login_ip')->comment('本次登录的ip')->nullable();
            $table->string('status')->comment('状态')->nullable(false);
            $table->tinyInteger('is_admin')->nullable();

            // 定义索引
            $table->unique('str_num');
            $table->timestamps();
            // 指定表存储引擎
            $table->engine = 'InnoDB';
            // 指定数据表的默认字符集
            $table->charset = 'utf8';
            // 指定数据表默认的排序规则
            $table->collation = 'utf8_unicode_ci';

        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('table_study');
    }
}
